<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class AlterTableOpenShopUserContract extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::statement("alter table open_shop_user_contract modify mode tinyint default 1 not null comment '加盟模式 1-传统模式 2分账模式,3定金模式'");

        Schema::table('open_shop_user_contract', function (Blueprint $table) {
            // tinyInteger 不支持修改
            //$table->tinyInteger('mode')->comment("加盟模式 1-传统模式 2分账模式,3定金模式")->change();

            $table->unsignedDecimal('depositAmountRatio',8,2)->default(0.00)->comment("分账模式：每月实收抽佣比例");
            $table->unsignedInteger('monthRealAmountCommissionCapping',)->default(0)->comment("分账模式：月实收抽佣封顶金额（元）, 单位：分");
            $table->tinyInteger('isCommissionCapping')->default(0)->comment("分账模式：是否抽佣累计封顶 0/1");
            $table->unsignedInteger('amountCommissionCapping')->default(0)->comment("分账模式：抽佣累计封顶金额（元）, 单位：分");
            $table->unsignedInteger('depositAmount')->default(0)->comment("定金模式：定金金额, 单位：分");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('open_shop_user_contract', function (Blueprint $table) {
            //$table->tinyInteger('mode')->comment("加盟模式 1-传统模式 2分账模式")->change();
            DB::statement("alter table open_shop_user_contract modify mode tinyint default 1 not null comment '加盟模式 1-传统模式 2分账模式'");
            $table->dropColumn(["depositAmountRatio","monthRealAmountCommissionCapping",'isCommissionCapping','amountCommissionCapping','depositAmount']);
        });
    }
}
